// 测试 JSON对象 中的方法

let student = {
    id: 1001,
    name: '得芳',
    gender: '靓妹'
}

console.log( typeof student );

// 将 JavaScript对象(即实例) 转换为 标准JSON格式字符串
let info = JSON.stringify( student );
console.log( info );
console.log( typeof info );

let arr = new Array('孙悟空', '蜘蛛侠', '奥特曼', '喜羊羊' );
console.log( typeof arr );

let str = JSON.stringify( arr );
console.log( str, typeof str );

console.log( '- '.repeat(30) );

const source = '{"id": 1001, "name": "阿芳", "gender": "female", "age": 18}';
console.log( typeof source );
// 将标准JSON格式字符串解析为 JavaScript对象(即实例)
let x = JSON.parse( source );
console.log( typeof x );
console.log( x.id, x.name, x.gender, x.age );

console.log( Array.isArray(JSON.parse('[1,3,5,7,9]')) );


// 参考文档：
// https://www.json.org/json-zh.html
// https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/JSON